// function includeExJS(jsFilepath){
//     var exJS = document.createElement('script');
//     exJS.src = jsFilepath;
//     document.head.appendChild(exJS);
// }
// includeExJS("/base.js");

export function getUrl() {
	return SG_API;
}

export function getNow(s) {
	return s < 10 ? '0' + s: s;
}

/**
 * 拼接完整请求路径
 */
export function spliceUrl(path) {
	return getUrl() + path
}

export function getAction(url, parameter) {
	return axios({
		url: url,
		method: "get",
		params: parameter,
	});
}

export function postAction(url, parameter) {
	return axios({
		url: url,
		method: "post",
		data: parameter,
	});
}
export function sum(arr) {
    let s = 0;
    for (let i=arr.length-1; i>=0; i--) {
        s += arr[i];
    }
    return s;
}

export function avg(dataIntArr) {
    let avg=0;
    for(let i=0;i<dataIntArr.length;i++){

        avg+=parseFloat(dataIntArr[i]);
    }
    if(dataIntArr.length==0){
        return 0;
    }else{
        return (avg/dataIntArr.length).toFixed(1);
    }
}

export function  remove(arr) {
    let arr1 = [];
    for(let i=0;i<arr.length;i++){
        if(arr[i]!='0'){
            arr1.push(arr[i])
        }
    }
    arr = arr1
    return arr
}
